import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import sun.misc.BASE64Encoder;
import sun.misc.CharacterEncoder;

/**
 * Contains one method, used for password encryption
 */
public class PasswordHash {
	private User user;
	private String value;

	/**
	 * Creates a new instance of PasswordHash
	 * 
	 * @param value
	 *            the encrypted password value
	 */
	public PasswordHash(String value) {
		this.user = null;
		this.value = value;
	}

	public PasswordHash() {
		this.user = null;
		this.value = null;
	}

	/**
	 * Creates a new instance of PasswordHash
	 * 
	 * @param user
	 *            the user
	 * @param value
	 *            the encrypted password value
	 */
	public PasswordHash(User user, String value) {
		this.user = user;
		this.value = value;
	}

	/**
	 * Returns the value of this PasswordHash, the encrypted password
	 * 
	 * @return the encrypted password
	 */
	public String getValue() {
		return value;
	}

	/**
	 * Sets the given encrypted value as the value of this PasswordHash
	 * 
	 * @param user
	 *            the user changing the password
	 * @param value
	 *            the value to be set
	 */
	public void setValue(String value) {
		this.value = value;
		// insert database editing stuph.
	}

	/**
	 * Determines whether the given PasswordHash is equal in value to the stored
	 * value of this PasswordHash
	 * 
	 * @param the
	 *            given PasswordHash
	 * @return true if they are equal in value
	 */
	public boolean equals(PasswordHash otherPasswordHash) {
		return this.value.equals(otherPasswordHash.getValue());
	}

	public String encrypt(String password) {
		// encrypt password later
		return password;
	}
}
